/*
 * @Author: your name
 * @Date: 2024-04-20 11:20:25
 * @LastEditTime: 2024-04-20 11:42:16
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \.leetcode\559.n-叉树的最大深度.cpp
 */
/*
 * @lc app=leetcode.cn id=559 lang=cpp
 *
 * [559] N 叉树的最大深度
 */

// @lc code=start
/*
// Definition for a Node.
class Node {
public:
    int val;
    vector<Node*> children;

    Node() {}

    Node(int _val) {
        val = _val;
    }

    Node(int _val, vector<Node*> _children) {
        val = _val;
        children = _children;
    }
};
*/

class Solution {
public:
    int getDepth(Node* node){
        if(!node) return 0;
        int tmp_max = 0;
        for(int i = 0; i < node->children.size(); i++){
            int depth = getDepth( node->children[i]);
            tmp_max = max(tmp_max, depth);
        }
        return tmp_max+1;
        
    }
    int maxDepth(Node* root) {
        return getDepth(root);
    }
};
// @lc code=end
/// max(tmp_max, depth);要有返回值啊

